﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace RestSubstringOccurrences
{
    
    public class RestOccurrencesService : IRestSubstringOccurrences
    {

        public string GetNumberOfOccurrences(string container, string substring)
        {
            int occurrences = 0;
            int index = 0;
            index = container.IndexOf(substring, index);
            while(index>=0)
            {
                occurrences++;
                index = container.IndexOf(substring, index + 1);
            }
            return occurrences.ToString();
        }
    }
}
